////#include<iostream>
////#include<set>
////const int N = 1e6 + 10;
////typedef long long ll;
////ll a[N],b[N],INF = N;
////using namespace std;
////int main()
////{
////	set<int> mp;
////	int m, n; cin >> m >> n;
////	mp.insert(-N);
////	for (int i = 1; i <= m; i++)
////	{
////		cin >> a[i];
////		mp.insert(a[i]);
////	}
////	for (int i = 1; i <= n; i++)
////	{
////		cin >> b[i];
////		auto p1 = mp.lower_bound(b[i]);
////		auto p2 = p1 - 
////	}
////	return 0;
////}
//#include<iostream>
//#include<algorithm>
//#include<cstdlib>
//const int N = 1e6 + 10;
//typedef long long ll;
//ll a[N], b[N];
//using namespace std;
//int main()
//{
//	int m, n;cin >> m >> n;
//	for (int i = 1; i <= m; i++)
//	{
//		cin >> a[i];
//	}ll sum = 0;
//	sort(a + 1, a + 1 + m);
//	for (int i = 1; i <= n; i++)
//	{
//		cin >> b[i];
//		int left = 1, right = m;
//		while (left < right)
//		{
//			int mid = (left + right) / 2;
//			if (a[mid] >= b[i]) right = mid;
//			else left = mid + 1;
//		}
//		int fina = left - 1;
//		if (left == 1) { sum += abs(a[left] - b[i]); continue; }
//		sum += min(abs(a[fina] - b[i]), abs(a[left] - b[i]));
//	}
//	cout << sum << endl;
//	return 0;
//}
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<set>
const int N = 1e6 + 10;
typedef long long ll;
ll a[N], b[N];
using namespace std;
int main()
{
	set<ll> mp;
	int m, n;cin >> m >> n;mp.insert(-N);
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i];
		mp.insert(a[i]);
	}ll sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
		auto p1 = mp.lower_bound(b[i]);
		auto p2 = p1--;
		sum += min(abs(*p1 - b[i]),abs(*p2 - b[i]));
	}
	cout << sum << endl;
	return 0;
}